package com.sunfield.windpower.util;

import com.sunfield.windpower.MyApplication;
import com.sunfield.windpower.bean.UserInfo;
import com.sunfield.windpower.pref.UserPref_;

/**
 * Created by wxl on 2017/5/26.
 */

public class UserUtil {

    private static UserPref_ pref;

    static {
        pref = new UserPref_(MyApplication.getInstance());
    }

    public static String getUserId(){
        return pref.userId().get();
    }

    public static String getCompanyId(){
        return pref.companyId().get();
    }

    public static void login(UserInfo userInfo){
        pref.edit().companyId().put(userInfo.getCompanyid()).userId().put(userInfo.getUserid()).apply();
    }

    public static void logout(){
        pref.clear();
    }
}
